package com.smbms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.smbms.mapper.BillMapper;
import com.smbms.pojo.Bill;
import com.smbms.service.BillService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BillServiceImpl implements BillService {

    @Resource
    private BillMapper billMapper;

    @Override
    public boolean add(Bill bill) {
        return billMapper.insert(bill) > 0;
    }

    @Override
    public List<Bill> getBillList(Bill bill) {
        return billMapper.getBillList(bill);
    }

    @Override
    public boolean deleteBillById(String delId) {
        QueryWrapper<Bill> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id", delId);
        return billMapper.delete(queryWrapper) > 0;
    }

    @Override
    public Bill getBillById(String id) {
        return billMapper.getBillById(id);
    }

    @Override
    public boolean modify(Bill bill) {
        QueryWrapper<Bill> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id", bill.getId());
        return billMapper.update(bill, queryWrapper) > 0;
    }

    @Override
    public int countByProId(String proId) {
        QueryWrapper<Bill> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("providerId",proId);
        return billMapper.selectCount(queryWrapper);
    }
}
